from django.contrib import admin
from .models import *


class StoryResponseInline(admin.StackedInline):
    # 内嵌模型
    model = StoryResponse


@admin.register(Story)
class Story(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "story_auther", "story_title", "story_img","story_short", "story_desc","story_praise","story_response"]
    # 搜索框
    search_fields = ["story_title", "story_auther"]
    # 过滤器
    list_filter = ["is_delete"]

    inlines = [StoryResponseInline]




@admin.register(StoryResponse)
class StoryResponseAdmin(admin.ModelAdmin):
    # 每页显示数据
    list_per_page = 10
    # 显示列
    list_display = ["id", "user_name", "response_story","story_id"]
    # 过滤器
    list_filter = ["story_id","is_delete"]
    # 搜索框
    search_fields = ["response_story"]








